//
//  Empty+Data.swift
//  RaveLand
//
//  Created by zhuxuhong on 2021/4/30.
//  Copyright © 2021 CSLY. All rights reserved.
//

import BWToolKit
import UIKit

public protocol EmptyDataWrapper {
    var value: Empty.Data {get}
}


extension Empty.Data: EmptyDataWrapper {
    public var value: Empty.Data {
        return self
    }
}

extension Empty.SenarioSet: EmptyDataWrapper {
    public var value: Empty.Data {
        return data
    }
}

extension Empty {
    class CustomSenarioSet {
        var sets: [AnyHashable: SenarioSet] = [:]
    }
}

extension Empty {
    public class SenarioSet: Hashable {
        public static func == (lhs: Empty.SenarioSet, rhs: Empty.SenarioSet) -> Bool {
            return lhs.senario == rhs.senario
        }
        public func hash(into hasher: inout Hasher) {
            hasher.combine(senario)
        }
        
        var senario: Senario
        var data: Empty.Data
        public init(senario: Senario, data: Data){
            self.senario = senario
            self.data = data
        }
    }
}

extension Empty {
    typealias StylingHandler = BlockT<EmptyView>
    
    public struct Data {
        public struct Action {
            var title: String?
            var icon: UIImage?
            var handler:  BlockVoid?
            var size: CGSize = .init(width: UIScreen.main.bounds.width/2, height: UIScreen.main.bounds.height/2)
            
            public init(icon: UIImage? = nil, title: String? = nil, handler: BlockVoid? = nil) {
                self.icon = icon
                self.title = title
                self.handler = handler
            }
        }
        
        var image: UIImage?
        var tips: String?
        var action: Action?
        var stylingHandler: Empty.StylingHandler?
        
        public init(
            image: UIImage? = nil,
            tips: String? = nil,
            action: Action? = nil
        ) {
            self.init(styling: nil, image: image, tips: tips, action: action)
        }
        
        public init(
            styling handler: BlockT<EmptyView>? = nil,
            image: UIImage? = nil,
            tips: String? = nil,
            action: Action? = nil
        ) {
            self.stylingHandler = handler
            self.image = image
            self.tips = tips
            self.action = action
        }
    }
}
